Give compare more data to work with so qsort is stable. From John
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Jul 2004 06:22:04 +0000 (06:22 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 22 Jul 2004 06:22:04 +0000 (06:22 +0000)
W. Temples, III

gpsbabel/netstumbler.c
gpsbabel/reference/netstumbler.mps

index 699c638654c1daa2f3f6d3ea675bd6c4b9cfee39..620cb1815dbc327953c8e9a7f2e8968f422f9fe4 100644 (file)
@@ -64,17 +64,17 @@ data_read(void)
        char ssid[2 + 32 + 2 + 1];                      /* "( " + SSID + " )" + null */
        char mac[2 + 17 + 2 + 1];                       /* "( " + MAC + " )" + null */
        char desc[sizeof ssid - 1 + 15 + 1];    /* room for channel/speed */
-       double lat,lon;
+       double lat = 0, lon = 0;
        waypoint *wpt_tmp;
        int line_no = 0;
        int stealth_num = 0, whitespace_num = 0;
-       long flags;
-       int speed, channel;
+       long flags = 0;
+       int speed = 0, channel = 0;
        struct tm tm;
 
        for(; fgets(ibuf, sizeof(ibuf), file_in);) {
                char *field;
-               int field_num, len, i, stealth;
+               int field_num, len, i, stealth = 0;
                
         /* A sharp in column zero might be a comment.  Or it might be
          * something useful, like the date.
@@ -223,8 +223,18 @@ compare(const void *a, const void *b)
                return -1;
        else if (crc_a > crc_b)
                return 1;
-       else
-               return 0;
+       else {
+               /* CRCs are equal; we need to subsort on the description (which
+                * includes the MAC address) to guarantee the same ordering of
+                * the output for any qsort() implementation.  this is strictly
+                * to make the testo script happy.
+                * */
+
+               waypoint *wpt_a = ((const htable_t *)a)->wpt;
+               waypoint *wpt_b = ((const htable_t *)b)->wpt;
+
+               return strcmp(wpt_a->description, wpt_b->description);
+       }
 }
 
 /* netstumbler data will have a lot of duplicate shortnames if the SSID
index 13e9dab0601ffa9d556e88e5710dac2d5dd18c97..c313182348d1eae58d4d4ff2e7046dd3296e030e 100644 (file)
Binary files a/gpsbabel/reference/netstumbler.mps and b/gpsbabel/reference/netstumbler.mps differ